package com.ganbo.stock.exception;

import com.ganbo.stock.enums.ExceptionCodes;
import lombok.Data;

/**
 * 公共异常
 *
 * @Author: ganbo
 * @Date: 2019/9/27 18:16
 */

@Data
public class CusException extends RuntimeException {

    private String code;

    public CusException(String coce, String message) {
        super(message);
        this.code = coce;
    }


    public static CusException build(ExceptionCodes exceptionCode) {
        return new CusException(exceptionCode.getCode(), exceptionCode.getDesc());
    }

    public static CusException build(ExceptionCodes exceptionCode, String msg) {
        return new CusException(exceptionCode.getCode(), msg);
    }

    public static CusException fail(String msg) {
        return new CusException(ExceptionCodes.FAIL.getCode(), msg);
    }


}
